/**
 * Created by Administrator on 2017/9/20.
 */
require.config({
	paths: {
		"jquery": "lib/jquery/jquery-3.2.1"
		
	}
});
require(["jquery"], function ($){
	$(function () {
		var $username=$("#login_username");
		var $upwd=$("#pass");
		var $confirmUpwd=$("#passs");
		var struserName = /^[a-zA-Z0-9_-]{4,16}$/;
		var strPassword=/^[a-zA-Z]\w{5,17}$/;
		$username.on("keyup",function () {
			if(!struserName.test($username.val())){
				$(".nameuser").css("display","block");
			}
			else $(".nameuser").hide();
		})
		$upwd.on("keyup",function () {
			if(!strPassword.test($upwd.val())){
				$(".password").css("display","block");
			}
			else $(".password").hide();
		})
		$confirmUpwd.on("keyup",function () {
			if(!$confirmUpwd.val()==$upwd.val()){
				$(".confirPass").css("display","block");
			}
			else $(".confirPass").hide();
		})
		$("#btn").on("click",function () {
			
			if(struserName.test($username.val())&&strPassword.test($upwd.val())&&$confirmUpwd.val()==$upwd.val()){
				$.ajax({
					url:"http://127.0.0.1/miya/resign.php",
					async:true,
					type:"post",
					data:{
						username:$username.val(),
						upwd:$upwd.val()
					},
					dataType:"json",
					success:function (res) {
						$("#confirm").text(res.msg).css("color","#fa4b9b")
					}
				})
			}
			
			
		})
		
		
	})
 
})